package com.itboye.jmsfhz.data.repository;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.utils.BaseErrorListener;
import com.itboye.core.utils.BaseSuccessReqListener;
import com.itboye.core.utils.ByJsonRequest.Builder;
import com.itboye.jmsfhz.data.interfaces.ILunBo;
import com.itboye.jmsfhz.data.model.HomePageModel;
import com.itboye.jmsfhz.data.model.LunBoModel;
import com.lfh.commentdemo.bean.AppModelNewsBean;

public class LunBoRepository extends BaseNetRepository implements
		ILunBo<LunBoModel> {
	public static final String Banner = "By_Banners_query";
	public  static final String SiFangHeZuo="By_Post_query";
	String api = "100";

	public LunBoRepository(ICompleteListener listener) {
		// TODO Auto-generated constructor stub
		super(listener);
	}

	@Override
	public void add(LunBoModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(LunBoModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(LunBoModel model) {
		// TODO Auto-generated method stub
		String apiVer = "100";
		Type type = new TypeToken<AppModelNewsBean>() {
		}.getType();
		Map<String, Object> map = new HashMap<String, Object>();
		(new Builder<AppModelNewsBean>())
				.setTypeVerParamsAndReturnClass(SiFangHeZuo, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<AppModelNewsBean>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void getInfo(LunBoModel model) {
		// TODO Auto-generated method stub
		String apiVer = api;
		Type type = new TypeToken<LunBoModel>() {
		}.getType();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("page_size",model.getPage_size());
		map.put("page_num", model.getPage_num());
		map.put("position", model.getPosition());
		(new Builder<LunBoModel>())
				.setTypeVerParamsAndReturnClass(Banner, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<LunBoModel>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public List<LunBoModel> query(LunBoModel model) {
		// TODO Auto-generated method stub
		return null;
	}

}
